package com.shop.admincontroller;

import com.shop.entity.SysPerssion;
import com.shop.service.SysPerssionService;
import com.shop.utils.ResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "资源管理")
@RequestMapping("/sysPerssion")
@RestController
public class SysPerssionController {

    @Autowired
    private SysPerssionService sysPerssionService;

    @ApiOperation("查询资源菜单")
    @GetMapping("/findPerssionResouce")
    public ResultUtils findPerssionResouce(@ApiParam(value = "每页显示多少条") @RequestParam(required = false) Integer size, @ApiParam(value = "当前页数") @RequestParam(required = false)Integer current){
        ResultUtils resultUtils= sysPerssionService.findPerssionResouce(current,size);
      return  resultUtils;
    }

    @ApiOperation("新增资源菜单")
    @GetMapping("/savePerssionResouce")
    public ResultUtils savePerssionResouce(SysPerssion sysPerssion){
        ResultUtils resultUtils= sysPerssionService.savePerssionResouce(sysPerssion);
        return  resultUtils;
    }


    @ApiOperation("删除资源菜单")
    @GetMapping("/deltePerssionResouce")
    public ResultUtils deltePerssionResouce(Integer id){
        ResultUtils resultUtils= sysPerssionService.deltePerssionResouce(id);
        return  resultUtils;
    }



    @ApiOperation("修改资源菜单")
    @GetMapping("/updatePerssionResouce")
    public ResultUtils updatePerssionResouce(SysPerssion sysPerssion){
        ResultUtils resultUtils= sysPerssionService.updatePerssionResouce(sysPerssion);
        return  resultUtils;
    }


    @ApiOperation("根据角色id查询菜单")
    @GetMapping("/findPerssionResouceByRoleId")
    public ResultUtils findPerssionResouceByRoleId(@RequestParam("id") List<Integer> id){
        ResultUtils resultUtils= sysPerssionService.findPerssionResouceByRoleId(id);
        return  resultUtils;
    }



}
